# Download zimfw script
readonly ZTARGET=${ZIM_HOME}/zimfw.zsh
if (
  command mkdir -p ${ZIM_HOME} || return 1
  readonly ZURL=https://gitee.com/dawn_magnet/zimfw/raw/master/zimfw.zsh
  if [[ ${+commands[curl]} -ne 0 && -x ${commands[curl]} ]]; then
    command curl -fsSL -o ${ZTARGET} ${ZURL} || return 1
  elif [[ ${+commands[wget]} -ne 0 && -x ${commands[wget]} ]]; then
    command wget -nv -O ${ZTARGET} ${ZURL} || return 1
  else
    print -u2 -P '%F{red}<%= error %>Either %Bcurl%b or %Bwget%b are required to download the Zim script.%f'
    return 1
  fi
); then
  print -PR "<%= okay %>Downloaded the Zim script to %B${ZTARGET}%b"
else
  command rm -rf ${ZIM_HOME}
  print -u2 -PR "%F{red}<%= error %>Could not download the Zim script to %B${ZTARGET}%b%f"
  return 1
fi
